<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>首页</title>
  <style type="text/css">
    h2 {
      text-align: center;
      color:deeppink;
    }
    table{
      margin: auto;
      width: 500px;
      text-align: center;
      border: 1px solid deeppink;
      border-right: 0;
      border-bottom: 0;
      color: #000;
    }
    table tr th {
      background-color: rgb(240, 191, 233);
    }
    table tr th,table tr td {
      border-right: 1px solid deeppink;
      border-bottom: 1px solid deeppink;
      height: 30px;
    }
    div {
      width: 500px;
      margin: auto;
      text-align: right;
      margin-bottom: 5px;
    }
    .op_btn {
      width: 120px;
    }
    .add_btn, .update_btn, .del_btn {
      cursor: pointer
    }
    .add_btn {
      background-color: deepskyblue;
      color:ghostwhite;
      border:1px solid deepskyblue;
    }
    .update_btn {
      background-color: rgb(62, 194, 68);
      color:ghostwhite;
      border:1px solid rgb(62, 194, 68);
    }
    .del_btn {
      background-color: rgb(238, 12, 50);
      color:ghostwhite;
      border:1px solid rgb(238, 12, 50);
    }
  </style>
</head>
<body>
  <h2>学生列表</h2>
  <div>
    <button class="add_btn" onclick="javascript:window.location.href='/toAdd';">新增</button>
  </div>
  <table cellpadding="0" cellspacing="0">
    <tr><th>序号</th><th>姓名</th><th>年龄</th><th>性别</th><th>操作</th></tr>
    <%for(var i=0;i<list.length;i++){%>
      <tr>
        <td><%=i+1%></td>
        <td><%=list[i].name%></td>
        <td><%=list[i].age%></td>
        <td><%=list[i].sex%></td>
        <td class="op_btn">
          <button class="update_btn" onclick="javascript:window.location.href='/toUpdate?id=<%=list[i]._id%>';">修改</button>
          <button class="del_btn" onclick="javascript:window.location.href='/delete?id=<%=list[i]._id%>';">删除</button>
        </td>
      </tr>
    <%}%>
  </table>
</body>
</html>